<template>
	<view class="">
		<view class="index-coupon">
			<scroll-view scroll-x="true" class="index-coupon-view">
				<view class="index-coupon-msg" v-for="(item,index ) in classList" :key="index">
					<view class="index-coupon-msg-msg" :class="activeTabIndex==index?'activeTab':''"
						@click="manuBtn(item,index)">
						{{item.name}}
					</view>
				</view>
			</scroll-view>

		</view>
		<view class="" style="height: 120rpx;">

		</view>
		<view class="list dis">
			<view class="list-msg" v-for="(item,index) in list" :key="index" @click="goPage(item)">
				<view class="list-msg-top">
					<image src="" mode=""></image>
					
				</view>
				<view class="list-msg-bot">{{item.cameraName}}</view>
			</view>
		</view>
		<home></home>
	</view>
</template>

<script>
	import {
		getCameraType,
		getCameraList
	} from '@/api/togeterRich/index.js'
	import home from '@/components/home/index.vue'
	export default {
		components: {
			home,
		},
		data() {
			return {
				classList: [],
				activeTabIndex: 0,
				list: [],
				cidData: {}
			}
		},
		onLoad() {
			this.init()

		},
		methods: {
			getList() {
				let data = {
					cid: this.cidData.id
				}
				getCameraList(data).then(res => {
					this.list = res.data.list
					console.log(res, '这世界哦列表')
				})
			},
			init() {
				getCameraType().then(resd => {
					this.classList = resd.data
					this.cidData = this.classList[0]
					this.getList()
				})
			},
			goPage(item) {
				uni.navigateTo({
					url: `/pagesA/fromClouds/info?tit=${item.cameraName}&&devCode=${item.devCode}&id=${item.id}`
					// url: `/pagesA/fromClouds/info?tit=` + item.tit
				})
			},
			manuBtn(item, index) {
				this.cidData = item
				console.log(item, '这是啥啊')
				this.activeTabIndex = index
				this.getList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		// justify-content: space-between;
		flex-wrap: wrap;

		.list-msg {
			padding: 20rpx;
			width: 45%;
			border-radius: 10rpx;
			background: #fff;
			margin: 10rpx auto;

			.list-msg-top {
				background: rgba(0, 0, 0, 0.7);
				width: 100%;
				height: 256rpx;
				text-align: center;
				display: flex;
				align-items: center;
				justify-content: center;


				image {
					width: 100rpx;
					height: 100rpx;
				}
			}

			.list-msg-bot {
				font-size: 26rpx;
				color: #000;
				padding: 30rpx 0px;
			}
		}
	}

	.activeTab {
		border-bottom: 4rpx solid $maincolor;
		color: $maincolor;
	}

	.index-coupon {
		position: fixed;
		top: 0;
		width: 100%;
		padding: 13px 20rpx;
		border-radius: 10rpx;

		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: baseline;


		.index-coupon-view {
			white-space: nowrap;
			padding: 15rpx 0;
			margin: 0 auto;

			.index-coupon-msg {
				.index-coupon-msg-msg {
					color: $maincolor;
					padding: 8rpx 20rpx;
					color: #000;

				}

				display: inline-block;
				opacity: 1;
				margin-right: 50rpx;
			}
		}


	}
</style>